Skip to content

Core

momapy.celldesigner.core

Classes:

Name Description
AndGate

Class for and gates

AndGateLayout

Class for and gate layouts

AntisenseRNA

Class for antisense RNAs

AntisenseRNALayout

Class for antisense RNA layouts

AntisenseRNATemplate

Class for antisense RNA templates

BooleanLogicGate

Base class for Boolean logic gates

Catalysis

Class for catalyses

CatalysisLayout

Class for catalysis layouts

Catalyzer

Class for catalyzers

CellDesignerDoubleHeadedArc

Base class for CellDesigner double-headed arcs

CellDesignerLayout

Class for CellDesigner layouts

CellDesignerMap

Class for CellDesigner maps

CellDesignerModel

Class for CellDesigner models

CellDesignerModelElement

Base class for CellDesigner model elements

CellDesignerNode

Base class for CellDesigner nodes

CellDesignerSingleHeadedArc

Base class for CellDesigner single-headed arcs

CodingRegion

Class for coding regions

Compartment

Class for compartments

Complex

Class for complexes

ComplexLayout

Class for complex layouts

ConsumptionLayout

Class for consumption layouts

Degraded

Class for degradeds

DegradedLayout

Class for degraded layouts

Dissociation

Class for dissociations

DissociationLayout

Class for dissociation layouts

Drug

Class for drugs

DrugLayout

Class for drug layouts

Gene

Class for genes

GeneLayout

Class for gene layouts

GeneTemplate

Class for gene templates

GenericProtein

Class for generic proteins

GenericProteinLayout

Class for generic protein layouts

GenericProteinTemplate

Class for generic protein templates

HeterodimerAssociation

Class for heterodimer associations

HeterodimerAssociationLayout

Class for heterodimer association layouts

Inhibition

Class for inhibitions

InhibitionLayout

Class for inhibition layouts

Inhibitor

Class for inhibitors

Ion

Class for ions

IonChannel

Class for ion channels

IonChannelLayout

Class for generic ion channel layouts

IonChannelTemplate

Class for ion channel templates

IonLayout

Class for ion layouts

KnownTransitionOmitted

Class for known transitions omitted

KnownTransitionOmittedLayout

Class for known transition omitted layouts

LogicArcLayout

Class for logic arc layouts

Modification

Class for modifications

ModificationLayout

Class for modification layouts

ModificationResidue

Class for modification residues

ModificationSite

Class for modification sites

ModificationState

Class for modification states

Modulation

Class for modulations

ModulationLayout

Class for modulation layouts

Modulator

Class for modulators

NegativeInfluence

Class for negative influences

NotGate

Class for not gates

NotGateLayout

Class for not gate layouts

OrGate

Class for or gates

OrGateLayout

Class for or gate layouts

OvalCompartmentLayout

Class for oval compartment layouts

Phenotype

Class for phenotypes

PhenotypeLayout

Class for phenotype layouts

PhysicalStimulation

Class for physical stimulations

PhysicalStimulationLayout

Class for physical stimulation layouts

PhysicalStimulator

Class for physical stimulators

PositiveInfluence

Class for positive influences

PositiveInfluenceLayout

Class for positive influence layouts

Product

Class for products

ProductionLayout

Class for production layouts

Protein

Base class for proteins

ProteinBindingDomain

Class for protein binding domains

ProteinTemplate

Base class for protein templates

RNA

Class for RNAs

RNALayout

Class for RNA layouts

RNATemplate

Class for RNA templates

Reactant

Class for reactants

Reaction

Base class for reactions

Receptor

Class for receptors

ReceptorLayout

Class for receptor layouts

ReceptorTemplate

Class for receptor templates

RectangleCompartmentLayout

Class for rectangle compartment layouts

Region

Class for regions

RegulatoryRegion

Class for regulatory regions

SimpleMolecule

Class for simple molecules

SimpleMoleculeLayout

Class for simple chemical layouts

Species

Base class for species

SpeciesTemplate

Base class for species templates

StateTransition

Class for state transitions

StateTransitionLayout

Class for state transition layouts

StructuralState

Class for structural states

StructuralStateLayout

Class for structural states layouts

Transcription

Class for transcriptions

TranscriptionLayout

Class for transcription layouts

TranscriptionStartingSiteL

Class for left transcription starting sites

TranscriptionStartingSiteR

Class for right transcription starting sites

Translation

Class for translation

TranslationLayout

Class for translation layouts

Transport

Class for transports

TransportLayout

Class for transport layouts

Trigger

Class for triggers

Triggering

Class for triggerings

TriggeringLayout

Class for triggering layouts

TruncatedProtein

Class for truncated proteins

TruncatedProteinLayout

Class for truncated protein layouts

TruncatedProteinTemplate

Class for truncated protein templates

Truncation

Class for truncations

TruncationLayout

Class for truncation layouts

Unknown

Class for unknown species

UnknownCatalysis

Class for unknown catalyses

UnknownCatalysisLayout

Class for unknown catalysis layouts

UnknownCatalyzer

Class for unknown catalyzers

UnknownGate

Class for unknown gates

UnknownGateLayout

Class for unknown gate layouts

UnknownInhibition

Class for unknown inhibitions

UnknownInhibitionLayout

Class for unknown inhibition layouts

UnknownInhibitor

Class for unknown inhibitors

UnknownLayout

Class for unknown species layouts

UnknownModulation

Class for unknown modulations

UnknownModulationLayout

Class for unknown modulation layouts

UnknownModulator

Class for unknown modulators

UnknownNegativeInfluence

Class for unknown negative influences

UnknownPhysicalStimulation

Class for unknown physical stimulations

UnknownPhysicalStimulationLayout

Class for unknown physical stimulation layouts

UnknownPositiveInfluence

Class for unknown positive influences

UnknownPositiveInfluenceLayout

Class for unknown positive influence layouts

UnknownTransition

Class for unknown transitions

UnknownTransitionLayout

Class for unknown transition layouts

UnknownTriggering

Class for unknown triggerings

UnknownTriggeringLayout

Class for unknown triggering layouts

AndGate dataclass

AndGate(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[Species] = frozenset()
)

Bases: BooleanLogicGate

Class for and gates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'5b675587-4858-4739-9852-df1e671e8ee4'

AndGateLayout dataclass

AndGateLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 15.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 15.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: _SimpleNodeMixin, _TextMixin, CellDesignerNode

Class for and gate layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'831bb35b-671e-4713-9bee-6c008d38e2fd'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
15.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
15.0
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

AntisenseRNA dataclass

AntisenseRNA(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    template: AntisenseRNATemplate,
    modifications: frozenset[Modification] = frozenset()
)

Bases: Species

Class for antisense RNAs

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'236fb9b0-ba8b-4591-8b63-a8a281cb784f'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1
template AntisenseRNATemplate
required

AntisenseRNALayout dataclass

AntisenseRNALayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    angle: float = 45.0
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for antisense RNA layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'b7c4ac2e-cc74-4fda-8c97-e1a9567a43f1'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
angle float
45.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 45.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/celldesigner/core.py
1634
1635
1636
1637
1638
1639
1640
1641
1642
def east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3() / 2 + shape.joint2() / 2

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1624
1625
1626
1627
1628
1629
1630
1631
1632
def east_north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3() * 0.25 + shape.joint2() * 0.75

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/celldesigner/core.py
1644
1645
1646
1647
1648
1649
1650
1651
1652
def east_south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3() * 0.75 + shape.joint2() * 0.25

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/celldesigner/core.py
1594
1595
1596
1597
1598
1599
1600
1601
1602
def north(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() / 2 + shape.joint2() / 2

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1614
1615
1616
1617
1618
1619
1620
1621
1622
def north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint2()

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1604
1605
1606
1607
1608
1609
1610
1611
1612
def north_north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() * 0.25 + shape.joint2() * 0.75

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1584
1585
1586
1587
1588
1589
1590
1591
1592
def north_north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() * 0.75 + shape.joint2() * 0.25

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1574
1575
1576
1577
1578
1579
1580
1581
1582
def north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1()

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/celldesigner/core.py
1674
1675
1676
1677
1678
1679
1680
1681
1682
def south(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() / 2 + shape.joint3() / 2

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/celldesigner/core.py
1654
1655
1656
1657
1658
1659
1660
1661
1662
def south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3()

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/celldesigner/core.py
1664
1665
1666
1667
1668
1669
1670
1671
1672
def south_south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.25 + shape.joint3() * 0.75

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1684
1685
1686
1687
1688
1689
1690
1691
1692
def south_south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.75 + shape.joint3() * 0.25

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1694
1695
1696
1697
1698
1699
1700
1701
1702
def south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4()

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/celldesigner/core.py
1714
1715
1716
1717
1718
1719
1720
1721
1722
def west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() / 2 + shape.joint1() / 2

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1724
1725
1726
1727
1728
1729
1730
1731
1732
def west_north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.25 + shape.joint1() * 0.75

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1704
1705
1706
1707
1708
1709
1710
1711
1712
def west_south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.75 + shape.joint1() * 0.25

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

AntisenseRNATemplate dataclass

AntisenseRNATemplate(
    *,
    id_: str = get_uuid4_as_str(),
    name: str,
    regions: frozenset[
        ModificationSite
        | CodingRegion
        | ProteinBindingDomain
    ] = frozenset()
)

Bases: SpeciesTemplate

Class for antisense RNA templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'34c0ed06-e253-4514-8a2d-e25c8a57eba5'
name str

The name of the species template

required

BooleanLogicGate dataclass

BooleanLogicGate(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[Species] = frozenset()
)

Bases: CellDesignerModelElement

Base class for Boolean logic gates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'46b4bf60-e5c1-4636-bb6b-a88e46dbe8b4'

Catalysis dataclass

Catalysis(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: Modulation

Class for catalyses

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'f9b16ce1-6b1f-44a1-aea4-5db031b2aea3'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

CatalysisLayout dataclass

CatalysisLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 7.0,
    arrowhead_width: float = 7.0
)

Bases: CellDesignerSingleHeadedArc

Class for catalysis layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'fcbca2ac-6cd8-4fb3-90c0-d653366242d7'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
7.0
arrowhead_width float
7.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Catalyzer dataclass

Catalyzer(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species | BooleanLogicGate
)

Bases: PhysicalStimulator

Class for catalyzers

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'5edd041c-8ba7-46f8-a284-49447f771834'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species | BooleanLogicGate

The species the modifier refers to

required

CellDesignerDoubleHeadedArc dataclass

CellDesignerDoubleHeadedArc(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: NoneValueType | Color | None = None,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = None,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = None,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = None,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = None,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = None,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: DoubleHeadedArc

Base class for CellDesigner double-headed arcs

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'fa319af6-07f8-431b-9ca4-d3a9efcc741b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None

The end arrowhead fill color of the arc

None
end_arrowhead_filter NoneValueType | Filter | None

The end arrowhead filter of the arc

None
end_arrowhead_stroke NoneValueType | Color | None

The end arrowhead stroke color of the arc

None
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The end arrowhead stroke dasharray of the arc

None
end_arrowhead_stroke_dashoffset float | None

The end arrowhead stroke dashoffset of the arc

None
end_arrowhead_stroke_width float | None

The end arrowhead stroke width of the arc

None
end_arrowhead_transform NoneValueType | tuple[Transformation] | None

The end arrowhead transform of the arc

None
start_arrowhead_fill NoneValueType | Color | None

The start arrowhead fill color of the arc

None
start_arrowhead_filter NoneValueType | Filter | None

The start arrowhead filter of the arc

None
start_arrowhead_stroke NoneValueType | Color | None

The start arrowhead stroke color of the arc

None
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The start arrowhead stroke dasharray of the arc

None
start_arrowhead_stroke_dashoffset float | None

The start arrowhead stroke dashoffset of the arc

None
start_arrowhead_stroke_width float | None

The start arrowhead stroke width of the arc

None
start_arrowhead_transform NoneValueType | tuple[Transformation] | None

The start arrowhead transform of the arc

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

CellDesignerLayout dataclass

CellDesignerLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    fill: NoneValueType | Color | None = NoneValue,
    filter: NoneValueType | Filter | None = None,
    height: float,
    label: TextLayout | None = None,
    position: Point,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = None
)

Bases: Layout

Class for CellDesigner layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'46dfebe5-1c6d-444a-bba7-490ed3bd17c4'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
filter NoneValueType | Filter | None

The filter of the node

None
height float

The height of the node

required
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None

The stroke color of the node

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None

The stroke width of the node

None
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float

The stroke width of the node

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

is_sublayout

Return true if another given layout is a sublayout of the layout, false otherwise

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

is_sublayout

is_sublayout(other, flattened=False, unordered=False)

Return true if another given layout is a sublayout of the layout, false otherwise

Source code in src/momapy/core.py
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
def is_sublayout(self, other, flattened=False, unordered=False):
    """Return `true` if another given layout is a sublayout of the layout, `false` otherwise"""

    def _is_sublist(list1, list2, unordered=False) -> bool:
        if not unordered:
            i = 0
            for elem1 in list1:
                elem2 = list2[i]
                while elem2 != elem1 and i < len(list2) - 1:
                    i += 1
                    elem2 = list2[i]
                if not elem2 == elem1:
                    return False
                i += 1
        else:
            dlist1 = collections.defaultdict(int)
            dlist2 = collections.defaultdict(int)
            for elem1 in list1:
                dlist1[elem1] += 1
            for elem2 in list2:
                dlist2[elem2] += 1
            for elem in dlist1:
                if dlist1[elem] > dlist2[elem]:
                    return False
        return True

    if self.childless() != other.childless():
        return False
    if flattened:
        return _is_sublist(
            self.flattened()[1:],
            other.flattened()[1:],
            unordered=unordered,
        )
    return _is_sublist(
        self.children(), other.children(), unordered=unordered
    )

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

CellDesignerMap dataclass

CellDesignerMap(
    *,
    id_: str = get_uuid4_as_str(),
    model: CellDesignerModel | None = None,
    layout: CellDesignerLayout | None = None,
    layout_model_mapping: LayoutModelMapping | None = None
)

Bases: Map

Class for CellDesigner maps

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0f30fb73-18e9-4444-8a12-c1b4aefcc67a'
model CellDesignerModel | None
None
layout CellDesignerLayout | None
None
layout_model_mapping LayoutModelMapping | None

The layout model mapping of the map

None

Methods:

Name Description
get_mapping

Return the layout elements mapped to the given model element

is_submap

Return true if another given map is a submap of the Map, false otherwise

get_mapping

get_mapping(
    key: (
        ModelElement | _MappingElementType | _MappingKeyType
    ),
    expand: bool = True,
    unpack: bool = False,
)

Return the layout elements mapped to the given model element

Source code in src/momapy/core.py
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
def get_mapping(
    self,
    key: ModelElement | _MappingElementType | _MappingKeyType,
    expand: bool = True,
    unpack: bool = False,
):
    """Return the layout elements mapped to the given model element"""
    return self.layout_model_mapping.get_mapping(
        key=key, expand=expand, unpack=unpack
    )

is_submap

is_submap(other)

Return true if another given map is a submap of the Map, false otherwise

Source code in src/momapy/core.py
1768
1769
1770
1771
1772
1773
1774
1775
1776
def is_submap(self, other):
    """Return `true` if another given map is a submap of the `Map`, `false` otherwise"""
    return (
        self.model.is_submodel(other.model)
        and self.layout.is_sublayout(other.layout)
        and self.layout_model_mapping.is_submapping(
            other.layout_model_mapping
        )
    )

CellDesignerModel dataclass

CellDesignerModel(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartments: frozenset[Compartment] = frozenset(),
    species: frozenset[Species] = frozenset(),
    reactions: frozenset[Reaction] = frozenset(),
    species_templates: frozenset[
        SpeciesTemplate
    ] = frozenset(),
    boolean_logic_gates: frozenset[
        BooleanLogicGate
    ] = frozenset(),
    modulations: frozenset[
        Modulation | UnknownModulation
    ] = frozenset()
)

Bases: Model

Class for CellDesigner models

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'6b2ffa2e-9f42-4ed9-a5bf-f1da13d0baac'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None

CellDesignerModelElement dataclass

CellDesignerModelElement(*, id_: str = get_uuid4_as_str())

Bases: ModelElement

Base class for CellDesigner model elements

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'9e487fdc-a3a0-485f-bdc7-c92ea386dcb3'

CellDesignerNode dataclass

CellDesignerNode(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = None
)

Bases: SBGNNode

Base class for CellDesigner nodes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'358fe1e3-b67a-48f6-8dbc-ffca538ce8fd'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float

The height of the node

required
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float

The stroke width of the node

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

CellDesignerSingleHeadedArc dataclass

CellDesignerSingleHeadedArc(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: SingleHeadedArc

Base class for CellDesigner single-headed arcs

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'b226c007-f59b-4211-8f2a-838c41566e36'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None

The arrowhead fill color of the arc

None
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

CodingRegion dataclass

CodingRegion(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    active: bool = False
)

Bases: Region

Class for coding regions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'cdbb70e5-c9a0-477d-9229-dd265229e473'
name str | None

The name of the region

None
active bool

Whether the region is active or not

False

Compartment dataclass

Compartment(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    outside: Optional[
        ForwardRef(Compartment, module=core)
    ] = None
)

Bases: Compartment, CellDesignerModelElement

Class for compartments

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'81da502d-1f41-4c55-a707-698962e0c283'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
outside ForwardRef(Compartment, module=core) | None
None

Complex dataclass

Complex(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    structural_states: frozenset[
        StructuralState
    ] = frozenset(),
    subunits: frozenset[Species] = frozenset()
)

Bases: Species

Class for complexes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'4910a194-9dca-474b-a0e0-d2eb1f7bcb4e'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1

ComplexLayout dataclass

ComplexLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    cut_corners: float = 6.0
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for complex layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0b7b5e3b-949a-4c67-bbff-3971feaecd9b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
cut_corners float
6.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

ConsumptionLayout dataclass

ConsumptionLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: CellDesignerSingleHeadedArc

Class for consumption layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'b53cf356-b30c-47c5-9625-ece9eeac2e08'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None

The arrowhead fill color of the arc

None
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Degraded dataclass

Degraded(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1
)

Bases: Species

Class for degradeds

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'b254bd90-0b4a-4b7a-8c0c-1f806b16ff41'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1

DegradedLayout dataclass

DegradedLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 30.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for degraded layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'10c8489e-f2e0-4a6a-a864-97c3cc01d4f5'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
30.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Dissociation dataclass

Dissociation(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for dissociations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'3622f82a-5da8-46da-bd09-9459b7b28169'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

DissociationLayout dataclass

DissociationLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = white,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_height: float = 10.0,
    end_arrowhead_sep: float = 2.0,
    end_arrowhead_width: float = 10.0,
    start_arrowhead_height: float = 8.0,
    start_arrowhead_width: float = 15.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for dissociation layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'd40d1f64-5d56-4fb5-a13e-b796cb72e13d'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_height float
10.0
end_arrowhead_sep float
2.0
end_arrowhead_width float
10.0
start_arrowhead_height float
8.0
start_arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Drug dataclass

Drug(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1
)

Bases: Species

Class for drugs

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e3da7cdf-55a1-48bc-b5c6-7e422d6719f7'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1

DrugLayout dataclass

DrugLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    horizontal_proportion: float = 0.2,
    sep: float = 4.0
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for drug layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'743950d7-e028-436a-a080-d176f2495d6b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
horizontal_proportion float
0.2
sep float
4.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Gene dataclass

Gene(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    template: GeneTemplate,
    modifications: frozenset[Modification] = frozenset()
)

Bases: Species

Class for genes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'f030bb2b-037a-48c9-9e0f-b1fcd92813d1'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1
template GeneTemplate
required

GeneLayout dataclass

GeneLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for gene layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'a2ccd3ad-16df-4927-a31b-cad1b8adbc43'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

GeneTemplate dataclass

GeneTemplate(
    *,
    id_: str = get_uuid4_as_str(),
    name: str,
    regions: frozenset[
        ModificationSite
        | CodingRegion
        | RegulatoryRegion
        | TranscriptionStartingSiteL
        | TranscriptionStartingSiteR
    ] = frozenset()
)

Bases: SpeciesTemplate

Class for gene templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'48ae88dc-0eea-4978-8e60-5525c08b6711'
name str

The name of the species template

required

GenericProtein dataclass

GenericProtein(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    template: GenericProteinTemplate,
    modifications: frozenset[Modification] = frozenset(),
    structural_states: frozenset[
        StructuralState
    ] = frozenset()
)

Bases: Protein

Class for generic proteins

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'9bc3515e-aca9-4a7a-9941-4953b17c0751'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1
template GenericProteinTemplate

The template of the generic protein

required

GenericProteinLayout dataclass

GenericProteinLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    rounded_corners: float = 5.0
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for generic protein layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'31262bab-6731-46e3-b42b-dfc2373c2e91'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

GenericProteinTemplate dataclass

GenericProteinTemplate(
    *,
    id_: str = get_uuid4_as_str(),
    name: str,
    modification_residues: frozenset[
        ModificationResidue
    ] = frozenset()
)

Bases: ProteinTemplate

Class for generic protein templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'28797ef8-8412-49cb-8c94-b04ad136a7a1'
name str

The name of the species template

required

HeterodimerAssociation dataclass

HeterodimerAssociation(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for heterodimer associations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e9a1e01a-ba43-4438-a533-54da44968141'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

HeterodimerAssociationLayout dataclass

HeterodimerAssociationLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_height: float = 8.0,
    end_arrowhead_width: float = 15.0,
    start_arrowhead_height: float = 6.0,
    start_arrowhead_width: float = 6.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for heterodimer association layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'4f238607-d49a-434a-968d-4405b7537c47'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_height float
8.0
end_arrowhead_width float
15.0
start_arrowhead_height float
6.0
start_arrowhead_width float
6.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Inhibition dataclass

Inhibition(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: Modulation

Class for inhibitions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'a6ec452b-ffa1-4385-81ca-f3688fd7bafe'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

InhibitionLayout dataclass

InhibitionLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 3.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0
)

Bases: CellDesignerSingleHeadedArc

Class for inhibition layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'd7407998-d5f8-440b-af8a-434b9c0fe181'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
3.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None

The arrowhead fill color of the arc

None
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Inhibitor dataclass

Inhibitor(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species | BooleanLogicGate
)

Bases: Modulator

Class for inhibitors

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'c099381c-9637-4b51-98cd-57154b9b21e7'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species | BooleanLogicGate

The species the modifier refers to

required

Ion dataclass

Ion(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1
)

Bases: Species

Class for ions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'2be4f1cd-eee6-489d-916b-89a755f2701f'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1

IonChannel dataclass

IonChannel(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    template: IonChannelTemplate,
    modifications: frozenset[Modification] = frozenset(),
    structural_states: frozenset[
        StructuralState
    ] = frozenset()
)

Bases: Protein

Class for ion channels

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'33283e2a-c906-4588-b9ee-b88579b3421f'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1
template IonChannelTemplate

The template of the ion channel

required

IonChannelLayout dataclass

IonChannelLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    rounded_corners: float = 5.0,
    right_rectangle_width: float = 20.0
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for generic ion channel layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'1d485eed-8b71-4ea8-944f-d40d1fff84cb'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
rounded_corners float
5.0
right_rectangle_width float
20.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

IonChannelTemplate dataclass

IonChannelTemplate(
    *,
    id_: str = get_uuid4_as_str(),
    name: str,
    modification_residues: frozenset[
        ModificationResidue
    ] = frozenset()
)

Bases: ProteinTemplate

Class for ion channel templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'24bd17d0-ab6f-45db-a66d-b047ab718940'
name str

The name of the species template

required

IonLayout dataclass

IonLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for ion layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'a0493a62-c46f-44f1-8c3f-c131642752a4'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

KnownTransitionOmitted dataclass

KnownTransitionOmitted(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for known transitions omitted

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'3c267113-8b0a-4128-b498-f4525d27c3ae'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

KnownTransitionOmittedLayout dataclass

KnownTransitionOmittedLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_height: float = 8.0,
    end_arrowhead_width: float = 15.0,
    start_arrowhead_height: float = 8.0,
    start_arrowhead_width: float = 15.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for known transition omitted layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0a27114f-98c1-43b4-a975-4adb30e77768'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_height float
8.0
end_arrowhead_width float
15.0
start_arrowhead_height float
8.0
start_arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

LogicArcLayout dataclass

LogicArcLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: CellDesignerSingleHeadedArc

Class for logic arc layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'74ef6ef5-40af-407f-bbee-47fe49fe8625'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None

The arrowhead fill color of the arc

None
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Modification dataclass

Modification(
    *,
    id_: str = get_uuid4_as_str(),
    residue: (
        ModificationResidue | ModificationSite | None
    ) = None,
    state: ModificationState | None = None
)

Bases: CellDesignerModelElement

Class for modifications

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'837000ca-de78-487f-b642-0e7a4e5ea4ed'
residue ModificationResidue | ModificationSite | None

The residue of the modification

None
state ModificationState | None

The state of the modification

None

ModificationLayout dataclass

ModificationLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 16.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 16.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: _SimpleNodeMixin, CellDesignerNode

Class for modification layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'9a14e4cb-a3c6-4b26-bd56-4040c0edbb8b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
16.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
16.0
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

ModificationResidue dataclass

ModificationResidue(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    order: int | None = None
)

Bases: CellDesignerModelElement

Class for modification residues

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'd9ff4841-52be-40d4-8ffa-c75231aafa1b'
name str | None
None
order int | None
None

ModificationSite dataclass

ModificationSite(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    active: bool = False
)

Bases: Region

Class for modification sites

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'cd22cd13-bba9-4a66-854c-cf6457f8eebd'
name str | None

The name of the region

None
active bool

Whether the region is active or not

False

ModificationState

Bases: Enum

Class for modification states

Modulation dataclass

Modulation(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: _Influence

Class for modulations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'915110e5-9e9a-45fc-8f84-f7c2ec15afdf'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

ModulationLayout dataclass

ModulationLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 8.0,
    arrowhead_width: float = 15.0
)

Bases: CellDesignerSingleHeadedArc

Class for modulation layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'32c9a431-0f6a-4770-b1ea-5ca24668e021'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
8.0
arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Modulator dataclass

Modulator(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species | BooleanLogicGate
)

Bases: _Modifier

Class for modulators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e1fbf799-9f9e-4abe-bb96-2a8677a52e57'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species | BooleanLogicGate

The species the modifier refers to

required

NegativeInfluence dataclass

NegativeInfluence(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: Modulation

Class for negative influences

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'03ab930b-0049-4fb3-960b-3bf61ce51528'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

NotGate dataclass

NotGate(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[Species] = frozenset()
)

Bases: BooleanLogicGate

Class for not gates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'80ebcbd5-dc3b-451d-902f-14e5a50cf842'

NotGateLayout dataclass

NotGateLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 15.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 15.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: _SimpleNodeMixin, _TextMixin, CellDesignerNode

Class for not gate layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'65b7c8ad-bc66-45c1-b0bf-dc8064c17634'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
15.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
15.0
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

OrGate dataclass

OrGate(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[Species] = frozenset()
)

Bases: BooleanLogicGate

Class for or gates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'26207812-ba21-4e72-a173-227b697a47eb'

OrGateLayout dataclass

OrGateLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 15.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 15.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: _SimpleNodeMixin, _TextMixin, CellDesignerNode

Class for or gate layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'7c90bc81-b744-4678-9fc1-cfc043ed58db'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
15.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
15.0
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

OvalCompartmentLayout dataclass

OvalCompartmentLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 16.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 16.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    inner_fill: NoneValueType | Color | None = white,
    inner_stroke: NoneValueType | Color | None = black,
    inner_stroke_width: float | None = 1.0,
    sep: float = 12.0
)

Bases: _SimpleNodeMixin, CellDesignerNode

Class for oval compartment layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'64b7f650-c44b-47ac-8f77-e68dc0709ea1'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
16.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
16.0
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
inner_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
inner_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
inner_stroke_width float | None
1.0
sep float
12.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Phenotype dataclass

Phenotype(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1
)

Bases: Species

Class for phenotypes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'7c38e877-6a87-4ebf-91d1-0fc82b8840b7'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1

PhenotypeLayout dataclass

PhenotypeLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    angle: float = 60.0
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for phenotype layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'1e67374d-9c74-48b4-b5e2-febfe4b68db3'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
angle float
60.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 60.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/celldesigner/core.py
1283
1284
1285
1286
1287
1288
1289
1290
1291
def east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3()

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1273
1274
1275
1276
1277
1278
1279
1280
1281
def east_north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3() / 2 + shape.joint2() / 2

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/celldesigner/core.py
1293
1294
1295
1296
1297
1298
1299
1300
1301
def east_south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() / 2 + shape.joint3() / 2

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/celldesigner/core.py
1243
1244
1245
1246
1247
1248
1249
1250
1251
def north(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() / 2 + shape.joint2() / 2

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1263
1264
1265
1266
1267
1268
1269
1270
1271
def north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint2()

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1253
1254
1255
1256
1257
1258
1259
1260
1261
def north_north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() * 0.25 + shape.joint2() * 0.75

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1233
1234
1235
1236
1237
1238
1239
1240
1241
def north_north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() * 0.75 + shape.joint2() * 0.25

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1223
1224
1225
1226
1227
1228
1229
1230
1231
def north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1()

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/celldesigner/core.py
1323
1324
1325
1326
1327
1328
1329
1330
1331
def south(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint5() / 2 + shape.joint4() / 2

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/celldesigner/core.py
1303
1304
1305
1306
1307
1308
1309
1310
1311
def south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4()

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/celldesigner/core.py
1313
1314
1315
1316
1317
1318
1319
1320
1321
def south_south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint5() * 0.25 + shape.joint4() * 0.75

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1333
1334
1335
1336
1337
1338
1339
1340
1341
def south_south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint5() * 0.75 + shape.joint4() * 0.25

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1343
1344
1345
1346
1347
1348
1349
1350
1351
def south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint5()

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/celldesigner/core.py
1363
1364
1365
1366
1367
1368
1369
1370
1371
def west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint6()

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1373
1374
1375
1376
1377
1378
1379
1380
1381
def west_north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint6() / 2 + shape.joint1() / 2

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1353
1354
1355
1356
1357
1358
1359
1360
1361
def west_south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint6() / 2 + shape.joint5() / 2

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

PhysicalStimulation dataclass

PhysicalStimulation(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: Modulation

Class for physical stimulations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ae22eb54-91e5-4872-b32b-98ecc6189452'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

PhysicalStimulationLayout dataclass

PhysicalStimulationLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0,
    arrowhead_width: float = 10.0
)

Bases: CellDesignerSingleHeadedArc

Class for physical stimulation layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'6d8ec003-fa2b-421d-ba42-8f3a170301ea'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0
arrowhead_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

PhysicalStimulator dataclass

PhysicalStimulator(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species | BooleanLogicGate
)

Bases: Modulator

Class for physical stimulators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'3ebbddf6-4d1f-4f34-95ab-7c1e2b961bd0'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species | BooleanLogicGate

The species the modifier refers to

required

PositiveInfluence dataclass

PositiveInfluence(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: Modulation

Class for positive influences

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'f4b9316f-a902-4daf-8d45-b5ee36c4886e'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

PositiveInfluenceLayout dataclass

PositiveInfluenceLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: (
        NoneValueType | Color | None
    ) = NoneValue,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 2.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0,
    arrowhead_width: float = 10.0
)

Bases: CellDesignerSingleHeadedArc

Class for positive influence layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'1e05ab8d-b2f2-4761-a063-f319956ab324'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
2.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0
arrowhead_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Product dataclass

Product(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species,
    stoichiometry: int | None = None,
    base: bool = False
)

Bases: SpeciesReference, CellDesignerModelElement

Class for products

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'1a5fa454-dbd9-4c26-97c5-f971e3c8487a'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species
required
stoichiometry int | None
None
base bool

Whether the product is a base product or not

False

ProductionLayout dataclass

ProductionLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = black,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 8.0,
    arrowhead_width: float = 15.0
)

Bases: CellDesignerSingleHeadedArc

Class for production layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'f1a3ad8a-5957-4ad6-9b2f-dab73744f846'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
8.0
arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Protein dataclass

Protein(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    template: ProteinTemplate,
    modifications: frozenset[Modification] = frozenset(),
    structural_states: frozenset[
        StructuralState
    ] = frozenset()
)

Bases: Species

Base class for proteins

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'177f2f1a-5bb4-45f7-94ae-00347ed2ce18'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1
template ProteinTemplate

The template of the species

required

ProteinBindingDomain dataclass

ProteinBindingDomain(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    active: bool = False
)

Bases: Region

Class for protein binding domains

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'552fbfe1-86fd-4584-ba50-97a86733632e'
name str | None

The name of the region

None
active bool

Whether the region is active or not

False

ProteinTemplate dataclass

ProteinTemplate(
    *,
    id_: str = get_uuid4_as_str(),
    name: str,
    modification_residues: frozenset[
        ModificationResidue
    ] = frozenset()
)

Bases: SpeciesTemplate

Base class for protein templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'942c668d-47d8-4ed1-b664-38f299d61406'
name str

The name of the species template

required

RNA dataclass

RNA(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    template: RNATemplate,
    modifications: frozenset[Modification] = frozenset()
)

Bases: Species

Class for RNAs

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'51234b8e-53a6-44e4-a37f-b538278d9b00'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1
template RNATemplate
required

RNALayout dataclass

RNALayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    angle: float = 45.0
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for RNA layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'8a152cde-bd47-4b33-af0e-0314d5bd9ea7'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
angle float
45.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 45.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/celldesigner/core.py
1457
1458
1459
1460
1461
1462
1463
1464
1465
def east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3() / 2 + shape.joint2() / 2

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1447
1448
1449
1450
1451
1452
1453
1454
1455
def east_north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3() * 0.25 + shape.joint2() * 0.75

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/celldesigner/core.py
1467
1468
1469
1470
1471
1472
1473
1474
1475
def east_south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3() * 0.75 + shape.joint2() * 0.25

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/celldesigner/core.py
1417
1418
1419
1420
1421
1422
1423
1424
1425
def north(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() / 2 + shape.joint2() / 2

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1437
1438
1439
1440
1441
1442
1443
1444
1445
def north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint2()

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1427
1428
1429
1430
1431
1432
1433
1434
1435
def north_north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() * 0.25 + shape.joint2() * 0.75

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1407
1408
1409
1410
1411
1412
1413
1414
1415
def north_north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() * 0.75 + shape.joint2() * 0.25

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1397
1398
1399
1400
1401
1402
1403
1404
1405
def north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1()

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/celldesigner/core.py
1497
1498
1499
1500
1501
1502
1503
1504
1505
def south(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() / 2 + shape.joint3() / 2

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/celldesigner/core.py
1477
1478
1479
1480
1481
1482
1483
1484
1485
def south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3()

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/celldesigner/core.py
1487
1488
1489
1490
1491
1492
1493
1494
1495
def south_south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.25 + shape.joint3() * 0.75

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1507
1508
1509
1510
1511
1512
1513
1514
1515
def south_south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.75 + shape.joint3() * 0.25

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1517
1518
1519
1520
1521
1522
1523
1524
1525
def south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4()

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/celldesigner/core.py
1537
1538
1539
1540
1541
1542
1543
1544
1545
def west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() / 2 + shape.joint1() / 2

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1547
1548
1549
1550
1551
1552
1553
1554
1555
def west_north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.25 + shape.joint1() * 0.75

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1527
1528
1529
1530
1531
1532
1533
1534
1535
def west_south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.75 + shape.joint1() * 0.25

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

RNATemplate dataclass

RNATemplate(
    *,
    id_: str = get_uuid4_as_str(),
    name: str,
    regions: frozenset[
        ModificationSite
        | CodingRegion
        | ProteinBindingDomain
    ] = frozenset()
)

Bases: SpeciesTemplate

Class for RNA templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'346ef718-1af9-4901-b08d-552b5c2c24da'
name str

The name of the species template

required

Reactant dataclass

Reactant(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species,
    stoichiometry: int | None = None,
    base: bool = False
)

Bases: SpeciesReference, CellDesignerModelElement

Class for reactants

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'84acfab8-439c-42fe-9589-c4768f6a912f'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species
required
stoichiometry int | None
None
base bool

Whether the reactant is a base reactant or not

False

Reaction dataclass

Reaction(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction, CellDesignerModelElement

Base class for reactions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'4c149794-7e00-42e2-994c-4ba370b84e63'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

Receptor dataclass

Receptor(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    template: ReceptorTemplate,
    modifications: frozenset[Modification] = frozenset(),
    structural_states: frozenset[
        StructuralState
    ] = frozenset()
)

Bases: Protein

Class for receptors

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0d475564-1eb6-4bbf-aa5d-f4bd25b24654'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1
template ReceptorTemplate

The template of the receptor

required

ReceptorLayout dataclass

ReceptorLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    vertical_truncation: float = 0.1
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for receptor layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'68efcca7-5196-4c44-be93-438ed47374c4'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
vertical_truncation float
0.1

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/celldesigner/core.py
1927
1928
1929
1930
1931
1932
1933
1934
1935
def east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() / 2 + shape.joint3() / 2

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1917
1918
1919
1920
1921
1922
1923
1924
1925
def east_north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.25 + shape.joint3() * 0.75

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/celldesigner/core.py
1937
1938
1939
1940
1941
1942
1943
1944
1945
def east_south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4() * 0.75 + shape.joint3() * 0.25

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/celldesigner/core.py
1887
1888
1889
1890
1891
1892
1893
1894
1895
def north(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint2()

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1907
1908
1909
1910
1911
1912
1913
1914
1915
def north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint3()

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/celldesigner/core.py
1897
1898
1899
1900
1901
1902
1903
1904
1905
def north_north_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint2() * 0.25 + shape.joint3() * 0.75

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1877
1878
1879
1880
1881
1882
1883
1884
1885
def north_north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1() / 2 + shape.joint2() / 2

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/celldesigner/core.py
1867
1868
1869
1870
1871
1872
1873
1874
1875
def north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint1()

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/celldesigner/core.py
1967
1968
1969
1970
1971
1972
1973
1974
1975
def south(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint5()

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/celldesigner/core.py
1947
1948
1949
1950
1951
1952
1953
1954
1955
def south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint4()

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/celldesigner/core.py
1957
1958
1959
1960
1961
1962
1963
1964
1965
def south_south_east(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint5() / 2 + shape.joint4() / 2

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1977
1978
1979
1980
1981
1982
1983
1984
1985
def south_south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint6() / 2 + shape.joint5() / 2

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1987
1988
1989
1990
1991
1992
1993
1994
1995
def south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint6()

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/celldesigner/core.py
2007
2008
2009
2010
2011
2012
2013
2014
2015
def west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint6() / 2 + shape.joint1() / 2

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/celldesigner/core.py
2017
2018
2019
2020
2021
2022
2023
2024
2025
def west_north_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint6() * 0.25 + shape.joint1() * 0.75

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/celldesigner/core.py
1997
1998
1999
2000
2001
2002
2003
2004
2005
def west_south_west(self) -> momapy.geometry.Point:
    width = self.width - self.offset * (self._n - 1)
    height = self.height - self.offset * (self._n - 1)
    position = self.position + (
        self.width / 2 - width / 2,
        self.height / 2 - height / 2,
    )
    shape = self._make_subunit_shape(position, width, height)
    return shape.joint6() * 0.75 + shape.joint1() * 0.25

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

ReceptorTemplate dataclass

ReceptorTemplate(
    *,
    id_: str = get_uuid4_as_str(),
    name: str,
    modification_residues: frozenset[
        ModificationResidue
    ] = frozenset()
)

Bases: ProteinTemplate

Class for receptor templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'80bffc3b-c562-46a1-b03b-39a52711eecf'
name str

The name of the species template

required

RectangleCompartmentLayout dataclass

RectangleCompartmentLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 16.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 16.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    inner_fill: NoneValueType | Color | None = white,
    inner_rounded_corners: float = 10.0,
    inner_stroke: NoneValueType | Color | None = black,
    inner_stroke_width: float | None = 1.0,
    rounded_corners: float = 10.0,
    sep: float = 12.0
)

Bases: _SimpleNodeMixin, CellDesignerNode

Class for rectangle compartment layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'5901d709-2623-4988-821d-217d8f489bd9'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
16.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
16.0
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
inner_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
inner_rounded_corners float
10.0
inner_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
inner_stroke_width float | None
1.0
rounded_corners float
10.0
sep float
12.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Region dataclass

Region(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    active: bool = False
)

Bases: CellDesignerModelElement

Class for regions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'a2250210-ee1a-4aff-af1b-38235864aaa2'
name str | None

The name of the region

None
active bool

Whether the region is active or not

False

RegulatoryRegion dataclass

RegulatoryRegion(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    active: bool = False
)

Bases: Region

Class for regulatory regions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'5e058d47-f294-440d-9040-b95f51e4fc94'
name str | None

The name of the region

None
active bool

Whether the region is active or not

False

SimpleMolecule dataclass

SimpleMolecule(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1
)

Bases: Species

Class for simple molecules

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'7e9cb318-fb00-4052-9f3f-74dff3c2bad6'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1

SimpleMoleculeLayout dataclass

SimpleMoleculeLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for simple chemical layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'178ec587-2a1d-4527-a88f-dca259580bc9'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Species dataclass

Species(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1
)

Bases: Species, CellDesignerModelElement

Base class for species

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'733f91e2-f0ed-43ee-8a62-a4f9398c5225'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1

SpeciesTemplate dataclass

SpeciesTemplate(
    *, id_: str = get_uuid4_as_str(), name: str
)

Bases: CellDesignerModelElement

Base class for species templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'7626ea42-1e04-45b1-ab2d-cc154e638c22'
name str

The name of the species template

required

StateTransition dataclass

StateTransition(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for state transitions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'010ae057-dc5d-4712-bfcb-5ae2db649f79'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

StateTransitionLayout dataclass

StateTransitionLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_height: float = 8.0,
    end_arrowhead_width: float = 15.0,
    start_arrowhead_height: float = 8.0,
    start_arrowhead_width: float = 15.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for state transition layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'63313fb8-91e2-44b5-850f-086305734c28'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_height float
8.0
end_arrowhead_width float
15.0
start_arrowhead_height float
8.0
start_arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

StructuralState dataclass

StructuralState(
    *,
    id_: str = get_uuid4_as_str(),
    value: str | None = None
)

Bases: CellDesignerModelElement

Class for structural states

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'a19b11d2-45e5-4bc6-b39a-191d420f6f33'
value str | None

The value of the structural state

None

StructuralStateLayout dataclass

StructuralStateLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 16.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 50.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: _SimpleNodeMixin, CellDesignerNode

Class for structural states layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ccfb14b8-9758-49ec-9560-d7b2bae803ec'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
16.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
50.0
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Transcription dataclass

Transcription(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for transcriptions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'9508c81a-a18e-4aef-ab83-6ded5a8732df'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

TranscriptionLayout dataclass

TranscriptionLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (12, 4, 2, 4, 2, 4),
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_height: float = 8.0,
    end_arrowhead_width: float = 15.0,
    start_arrowhead_height: float = 8.0,
    start_arrowhead_width: float = 15.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for transcription layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'94248254-85ca-4986-b3b5-c1b8c31c9095'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None
(12, 4, 2, 4, 2, 4)
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_height float
8.0
end_arrowhead_width float
15.0
start_arrowhead_height float
8.0
start_arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

TranscriptionStartingSiteL dataclass

TranscriptionStartingSiteL(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    active: bool = False
)

Bases: Region

Class for left transcription starting sites

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'df506c3e-ee0c-4ebe-a555-44d2bb76da3b'
name str | None

The name of the region

None
active bool

Whether the region is active or not

False

TranscriptionStartingSiteR dataclass

TranscriptionStartingSiteR(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    active: bool = False
)

Bases: Region

Class for right transcription starting sites

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'48970f4b-2dbd-4013-8630-ebda04c02801'
name str | None

The name of the region

None
active bool

Whether the region is active or not

False

Translation dataclass

Translation(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for translation

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0084f158-f3b4-4cff-ab30-9ab2d1fa0082'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

TranslationLayout dataclass

TranslationLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (12, 4, 2, 4),
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_height: float = 8.0,
    end_arrowhead_width: float = 15.0,
    start_arrowhead_height: float = 8.0,
    start_arrowhead_width: float = 15.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for translation layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'979f59d4-f273-4a71-a26b-06bac79b8986'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None
(12, 4, 2, 4)
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_height float
8.0
end_arrowhead_width float
15.0
start_arrowhead_height float
8.0
start_arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Transport dataclass

Transport(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for transports

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'316d8d46-2e89-4535-90a8-912f8fd4bb93'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

TransportLayout dataclass

TransportLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_bar_height: float = 8.0,
    end_arrowhead_sep: float = 5.0,
    end_arrowhead_triangle_height: float = 8.0,
    end_arrowhead_triangle_width: float = 15.0,
    start_arrowhead_bar_height: float = 8.0,
    start_arrowhead_sep: float = 4.0,
    start_arrowhead_triangle_height: float = 8.0,
    start_arrowhead_triangle_width: float = 15.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for transport layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'b8b1eb3c-8a40-4b3f-8dbc-b6931c297631'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_bar_height float
8.0
end_arrowhead_sep float
5.0
end_arrowhead_triangle_height float
8.0
end_arrowhead_triangle_width float
15.0
start_arrowhead_bar_height float
8.0
start_arrowhead_sep float
4.0
start_arrowhead_triangle_height float
8.0
start_arrowhead_triangle_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Trigger dataclass

Trigger(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species | BooleanLogicGate
)

Bases: Modulator

Class for triggers

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'21e529c5-1215-4b87-826a-d9ff2b7f624f'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species | BooleanLogicGate

The species the modifier refers to

required

Triggering dataclass

Triggering(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: Modulation

Class for triggerings

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'8f0cc64f-22de-4c66-848f-bdfa5ac4ea98'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

TriggeringLayout dataclass

TriggeringLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_bar_height: float = 8.0,
    arrowhead_sep: float = 5.0,
    arrowhead_triangle_height: float = 10.0,
    arrowhead_triangle_width: float = 15.0
)

Bases: CellDesignerSingleHeadedArc

Class for triggering layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'd6f198b5-5f13-4b3b-902a-908eba7e3a3b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_bar_height float
8.0
arrowhead_sep float
5.0
arrowhead_triangle_height float
10.0
arrowhead_triangle_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

TruncatedProtein dataclass

TruncatedProtein(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1,
    template: TruncatedProteinTemplate,
    modifications: frozenset[Modification] = frozenset(),
    structural_states: frozenset[
        StructuralState
    ] = frozenset()
)

Bases: Protein

Class for truncated proteins

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'd904e94a-0294-4d6f-a78f-9e7fc8d314dd'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1
template TruncatedProteinTemplate

The template of the truncated protein

required

TruncatedProteinLayout dataclass

TruncatedProteinLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1,
    rounded_corners: float = 15.0,
    vertical_truncation: float = 0.4,
    horizontal_truncation: float = 0.2
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for truncated protein layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'c683ab00-fd6f-4cb9-8f91-cf9d31a66f5b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1
rounded_corners float
15.0
vertical_truncation float
0.4
horizontal_truncation float
0.2

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

TruncatedProteinTemplate dataclass

TruncatedProteinTemplate(
    *,
    id_: str = get_uuid4_as_str(),
    name: str,
    modification_residues: frozenset[
        ModificationResidue
    ] = frozenset()
)

Bases: ProteinTemplate

Class for truncated protein templates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ea3c175d-bad8-4d0c-9098-b6d351de39e2'
name str

The name of the species template

required

Truncation dataclass

Truncation(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for truncations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'c611d01b-c8d0-46f6-8edc-2c02efd7d4b2'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

TruncationLayout dataclass

TruncationLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = white,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_height: float = 10.0,
    end_arrowhead_sep: float = 2.0,
    end_arrowhead_width: float = 10.0,
    start_arrowhead_height: float = 8.0,
    start_arrowhead_width: float = 15.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for truncation layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'9c286b5f-924f-4deb-b155-2e2e82a15828'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_height float
10.0
end_arrowhead_sep float
2.0
end_arrowhead_width float
10.0
start_arrowhead_height float
8.0
start_arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Unknown dataclass

Unknown(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    compartment: Compartment | None = None,
    hypothetical: bool = False,
    active: bool = False,
    homomultimer: int = 1
)

Bases: Species

Class for unknown species

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e06f8a8c-e5d0-4ef3-b0a4-1f87f706af93'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
compartment Compartment | None
None
hypothetical bool

Whether the species is hypothetical or not

False
active bool

Whether the species is active or not

False
homomultimer int

The number of subunits forming the species

1

UnknownCatalysis dataclass

UnknownCatalysis(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: UnknownModulation

Class for unknown catalyses

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'24cdd199-8bcb-4427-a5be-6bed2fde49ce'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

UnknownCatalysisLayout dataclass

UnknownCatalysisLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (12, 4),
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 7.0,
    arrowhead_width: float = 7.0
)

Bases: CellDesignerSingleHeadedArc

Class for unknown catalysis layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'66357df5-d901-44d4-b9bb-d2df9e60c2df'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None
(12, 4)
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
7.0
arrowhead_width float
7.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

UnknownCatalyzer dataclass

UnknownCatalyzer(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species | BooleanLogicGate
)

Bases: UnknownModulator

Class for unknown catalyzers

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'221e3c12-08cc-44b0-813e-3d752b1c9970'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species | BooleanLogicGate

The species the modifier refers to

required

UnknownGate dataclass

UnknownGate(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[Species] = frozenset()
)

Bases: BooleanLogicGate

Class for unknown gates

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'f739907e-1067-40f7-a36a-ff9c061939f2'

UnknownGateLayout dataclass

UnknownGateLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 15.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 15.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: _SimpleNodeMixin, _TextMixin, CellDesignerNode

Class for unknown gate layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'99c85a77-5afa-4604-bbf7-b27f8639b18b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
15.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
15.0
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

UnknownInhibition dataclass

UnknownInhibition(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: UnknownModulation

Class for unknown inhibitions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'f0ee1a3b-6d9e-40c5-8a20-d62189e23a08'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

UnknownInhibitionLayout dataclass

UnknownInhibitionLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 3.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (12, 4),
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0
)

Bases: CellDesignerSingleHeadedArc

Class for unknown inhibition layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'af25eeb2-710d-42a3-b5ba-7fb700e4b1a0'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
3.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None
(12, 4)
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None

The arrowhead fill color of the arc

None
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

UnknownInhibitor dataclass

UnknownInhibitor(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species | BooleanLogicGate
)

Bases: UnknownModulator

Class for unknown inhibitors

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'184664a4-4fcd-47b0-9aa3-8606ea8f9259'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species | BooleanLogicGate

The species the modifier refers to

required

UnknownLayout dataclass

UnknownLayout(
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    fill: NoneValueType | Color | None = gray,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke: NoneValueType | Color | None = NoneValue,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    active: bool = False,
    active_fill: NoneValueType | Color | None = NoneValue,
    active_filter: NoneValueType | Filter | None = None,
    active_sep: float = 4.0,
    active_stroke: NoneValueType | Color | None = black,
    active_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (4, 2),
    active_stroke_dashoffset: float | None = None,
    active_stroke_width: float | None = 1.0,
    active_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    n: int = 1
)

Bases: _MultiNodeMixin, CellDesignerNode

Class for unknown species layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'd8610650-6895-4657-82a4-76d234562706'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=128, green=128, blue=128, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
active bool
False
active_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
active_filter NoneValueType | Filter | None
None
active_sep float
4.0
active_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
active_stroke_dasharray NoneValueType | tuple[float] | None
(4, 2)
active_stroke_dashoffset float | None
None
active_stroke_width float | None
1.0
active_transform NoneValueType | tuple[Transformation] | None
None
n int
1

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

UnknownModulation dataclass

UnknownModulation(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: _Influence

Class for unknown modulations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ffa74101-8fc3-4300-a793-f9bf2470b254'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

UnknownModulationLayout dataclass

UnknownModulationLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (12, 4),
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 8.0,
    arrowhead_width: float = 15.0
)

Bases: CellDesignerSingleHeadedArc

Class for unknown modulation layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'20eb3360-7b29-461f-b274-ebd9c6006d57'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None
(12, 4)
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
8.0
arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

UnknownModulator dataclass

UnknownModulator(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    referred_species: Species | BooleanLogicGate
)

Bases: _Modifier

Class for unknown modulators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'5207e165-e336-46cd-80b8-70ab4c1260c4'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
referred_species Species | BooleanLogicGate

The species the modifier refers to

required

UnknownNegativeInfluence dataclass

UnknownNegativeInfluence(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: UnknownModulation

Class for unknown negative influences

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'df0c4607-2569-464e-90a8-4b871639a195'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

UnknownPhysicalStimulation dataclass

UnknownPhysicalStimulation(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: UnknownModulation

Class for unknown physical stimulations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'800ef892-e34b-426d-b048-6431f8843ae0'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

UnknownPhysicalStimulationLayout dataclass

UnknownPhysicalStimulationLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (12, 4),
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0,
    arrowhead_width: float = 10.0
)

Bases: CellDesignerSingleHeadedArc

Class for unknown physical stimulation layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'183b32c0-7570-4944-909c-4daa3ee99107'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None
(12, 4)
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0
arrowhead_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

UnknownPositiveInfluence dataclass

UnknownPositiveInfluence(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: UnknownModulation

Class for unknown positive influences

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'9da4d562-49f9-4608-affa-78478482d435'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

UnknownPositiveInfluenceLayout dataclass

UnknownPositiveInfluenceLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (12, 4),
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: (
        NoneValueType | Color | None
    ) = NoneValue,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 2.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0,
    arrowhead_width: float = 10.0
)

Bases: CellDesignerSingleHeadedArc

Class for unknown positive influence layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0a9463cc-e8e4-494a-aa2a-23cade1c5957'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None
(12, 4)
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
2.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0
arrowhead_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

UnknownTransition dataclass

UnknownTransition(
    *,
    id_: str = get_uuid4_as_str(),
    name: str | None = None,
    sbo_term: SBOTerm | None = None,
    metaid: str | None = None,
    reversible: bool,
    compartment: Compartment | None = None,
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    modifiers: frozenset[
        Modulator | UnknownModulator
    ] = frozenset()
)

Bases: Reaction

Class for unknown transitions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'13bf6342-1429-4ff6-b661-d7de61ef3544'
name str | None
None
sbo_term SBOTerm | None
None
metaid str | None
None
reversible bool
required
compartment Compartment | None
None

UnknownTransitionLayout dataclass

UnknownTransitionLayout(
    *,
    _left_connector_fraction: float = 0.4,
    _right_connector_fraction: float = 0.6,
    reaction_node_height: float = 10.0,
    reaction_node_width: float = 10.0,
    reaction_node_segment: int = 1,
    reaction_node_stroke: (
        NoneValueType | Color | None
    ) = black,
    reaction_node_stroke_width: float | None = 1.0,
    reaction_node_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    reaction_node_stroke_dashoffset: float | None = None,
    reaction_node_fill: (
        NoneValueType | Color | None
    ) = white,
    reaction_node_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reaction_node_filter: (
        NoneValueType | Filter | None
    ) = None,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 2.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 2.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    end_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    end_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    end_arrowhead_stroke_dashoffset: float | None = None,
    end_arrowhead_stroke_width: float | None = 1.0,
    end_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    start_arrowhead_fill: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_filter: (
        NoneValueType | Filter | None
    ) = None,
    start_arrowhead_stroke: (
        NoneValueType | Color | None
    ) = black,
    start_arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    start_arrowhead_stroke_dashoffset: float | None = None,
    start_arrowhead_stroke_width: float | None = 1.0,
    start_arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    reversible: bool = False,
    end_arrowhead_height: float = 8.0,
    end_arrowhead_width: float = 15.0,
    start_arrowhead_height: float = 8.0,
    start_arrowhead_width: float = 15.0
)

Bases: _ReactionLayout, _ReactionNodeMixin

Class for unknown transition layouts

Parameters:

Name Type Description Default
_left_connector_fraction float
0.4
_right_connector_fraction float
0.6
reaction_node_height float
10.0
reaction_node_width float
10.0
reaction_node_segment int
1
reaction_node_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
reaction_node_stroke_width float | None
1.0
reaction_node_stroke_dasharray NoneValueType | tuple[float] | None
None
reaction_node_stroke_dashoffset float | None
None
reaction_node_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
reaction_node_transform NoneValueType | tuple[Transformation] | None
None
reaction_node_filter NoneValueType | Filter | None
None
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'958543b0-e17b-4351-89ee-bcb3c57f1edb'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float
2.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float
2.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
end_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_filter NoneValueType | Filter | None
None
end_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
end_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
end_arrowhead_stroke_dashoffset float | None
None
end_arrowhead_stroke_width float | None
1.0
end_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
start_arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_filter NoneValueType | Filter | None
None
start_arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
start_arrowhead_stroke_dasharray NoneValueType | tuple[float] | None
None
start_arrowhead_stroke_dashoffset float | None
None
start_arrowhead_stroke_width float | None
1.0
start_arrowhead_transform NoneValueType | tuple[Transformation] | None
None
reversible bool
False
end_arrowhead_height float
8.0
end_arrowhead_width float
15.0
start_arrowhead_height float
8.0
start_arrowhead_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_arrowhead_base

Return the base anchor point of the double-headed arc end arrowhead

end_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

end_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.

end_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc end arrowhead

end_arrowhead_length

Return the length of the double-headed arc end arrowhead

end_arrowhead_tip

Return the tip anchor point of the double-headed arc end arrowhead

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the double-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_arrowhead_base

Return the base anchor point of the double-headed arc start arrowhead

start_arrowhead_bbox

Return the bounding box of the double-headed arc start arrowhead

start_arrowhead_border

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.

start_arrowhead_drawing_elements

Return the drawing elements of the double-headed arc start arrowhead

start_arrowhead_length

Return the length of the double-headed arc start arrowhead

start_arrowhead_tip

Return the tip anchor point of the double-headed arc start arrowhead

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_arrowhead_base

end_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
def end_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc end arrowhead"""
    arrowhead_length = self.end_arrowhead_length()
    if arrowhead_length == 0:
        return self.end_point()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.end_arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

end_arrowhead_bbox

end_arrowhead_bbox()

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1400
1401
1402
1403
1404
def end_arrowhead_bbox(self):
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.end_arrowhead_drawing_elements()
    )

end_arrowhead_border

end_arrowhead_border(point)

Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
def end_arrowhead_border(self, point):
    """Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.end_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.end_arrowhead_tip()
    return point

end_arrowhead_drawing_elements

end_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
def end_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc end arrowhead"""
    elements = self._end_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_end_arrowhead",
        elements=elements,
        fill=self.end_arrowhead_fill,
        filter=self.end_arrowhead_filter,
        id_=f"{self.id_}_end_arrowhead",
        stroke=self.end_arrowhead_stroke,
        stroke_width=self.end_arrowhead_stroke_width,
        stroke_dasharray=self.end_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.end_arrowhead_stroke_dashoffset,
        transform=self.end_arrowhead_transform,
    )
    transformation = self._get_end_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

end_arrowhead_length

end_arrowhead_length() -> float

Return the length of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1370
1371
1372
1373
1374
1375
1376
1377
def end_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc end arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._end_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

end_arrowhead_tip

end_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc end arrowhead

Source code in src/momapy/core.py
1379
1380
1381
1382
1383
1384
1385
1386
def end_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc end arrowhead"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the double-headed arc path

Source code in src/momapy/core.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the double-headed arc path"""
    start_arrowhead_length = self.start_arrowhead_length()
    end_arrowhead_length = self.end_arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(
                self.start_shorten + start_arrowhead_length, "start"
            )
            .shortened(self.end_shorten + end_arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten + start_arrowhead_length, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + end_arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead

Source code in src/momapy/celldesigner/core.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerDoubleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_arrowhead_base

start_arrowhead_base() -> Point

Return the base anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
def start_arrowhead_base(self) -> momapy.geometry.Point:
    """Return the base anchor point of the double-headed arc start arrowhead"""
    arrowhead_length = self.start_arrowhead_length()
    if arrowhead_length == 0:
        return self.start_point()
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return self.start_arrowhead_tip() + (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.start_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

start_arrowhead_bbox

start_arrowhead_bbox() -> Bbox

Return the bounding box of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1353
1354
1355
1356
1357
def start_arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the double-headed arc start arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.start_arrowhead_drawing_elements()
    )

start_arrowhead_border

start_arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def start_arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    point = momapy.drawing.get_drawing_elements_border(
        self.start_arrowhead_drawing_elements(), point
    )
    if point.isnan():
        return self.start_arrowhead_tip()
    return point

start_arrowhead_drawing_elements

start_arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
def start_arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the double-headed arc start arrowhead"""
    elements = self._start_arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_start_arrowhead",
        elements=elements,
        id_=f"{self.id_}_start_arrowhead",
        fill=self.start_arrowhead_fill,
        filter=self.start_arrowhead_filter,
        stroke=self.start_arrowhead_stroke,
        stroke_dasharray=self.start_arrowhead_stroke_dasharray,
        stroke_dashoffset=self.start_arrowhead_stroke_dashoffset,
        stroke_width=self.start_arrowhead_stroke_width,
        transform=self.start_arrowhead_transform,
    )
    transformation = self._get_start_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

start_arrowhead_length

start_arrowhead_length() -> float

Return the length of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1321
1322
1323
1324
1325
1326
1327
1328
def start_arrowhead_length(self) -> float:
    """Return the length of the double-headed arc start arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._start_arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return abs(bbox.west().x)

start_arrowhead_tip

start_arrowhead_tip() -> Point

Return the tip anchor point of the double-headed arc start arrowhead

Source code in src/momapy/core.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
def start_arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the tip anchor point of the double-headed arc start arrowhead"""
    segment = self.segments[0]
    segment = momapy.geometry.Segment(segment.p2, segment.p1)
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.start_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

UnknownTriggering dataclass

UnknownTriggering(
    *,
    id_: str = get_uuid4_as_str(),
    source: Species | BooleanLogicGate,
    target: Species | None
)

Bases: UnknownModulation

Class for unknown triggerings

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'8bb8433b-b450-4b03-a50d-c1a1534934e3'
source Species | BooleanLogicGate

The source of the influence

required
target Species | None

The target of the influence

required

UnknownTriggeringLayout dataclass

UnknownTriggeringLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_fill: NoneValueType | Color | None = NoneValue,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = (12, 4),
    path_stroke_dashoffset: float | None = None,
    path_stroke_width: float | None = 1.0,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_stroke_width: float | None = 1.0,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_bar_height: float = 8.0,
    arrowhead_sep: float = 5.0,
    arrowhead_triangle_height: float = 10.0,
    arrowhead_triangle_width: float = 15.0
)

Bases: CellDesignerSingleHeadedArc

Class for unknown triggering layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'cb8ffc01-c88c-4c38-8b74-c58cb67b9fe3'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None
(12, 4)
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.0
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.0
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_bar_height float
8.0
arrowhead_sep float
5.0
arrowhead_triangle_height float
10.0
arrowhead_triangle_width float
15.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements()

Return the self drawing elements of the single-headed arc

Source code in src/momapy/celldesigner/core.py
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def self_drawing_elements(self):
    drawing_elements = momapy.builder.super_or_builder(
        CellDesignerSingleHeadedArc, self
    ).self_drawing_elements()
    done_bases = []
    for base in type(self).__mro__:
        if (
            momapy.builder.issubclass_or_builder(
                base, momapy.sbgn.core._SBGNMixin
            )
            and base is not type(self)
            and not any(
                [issubclass(done_base, base) for done_base in done_bases]
            )
        ):
            drawing_elements += getattr(base, "_mixin_drawing_elements")(
                self
            )
            done_bases.append(base)
    return drawing_elements

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)